/*
 * DatosCompartidos.java
 * Copyright (c) 2006, FMap
 *
 * Created on 7 de febrero de 2006, 23:03
 */

package fmap;

import fmap.actions.cat.GetCatsAction;
import fmap.dao.CollectionDao;
import fmap.gui.JFrameMain;
import fmap.gui.JFrameAdminCollection;
import fmap.gui.JFrameNewMapF;
import fmap.gui.JFrameSearchAdvanced;
import fmap.gui.JPanelRight;
import fmap.gui.jTablePersonal.JTablePersonal;
import fmap.gui.jTablePersonal.JTablePersonalResultSearch;
import fmap.gui.jTreePersonal.JTreePersonal;
import fmap.gui.jTreePersonal.JTreeResultSearch;
import fmap.model.Cat;
import fmap.model.Collection;
import fmap.model.GroupFile;
import fmap.model.MapF;
import fmap.model.Node;
import java.io.File;
import java.util.Hashtable;


/**
 * Contiene todas las referencias estáticas a 
 * los componentes y objectos comunes
 *
 * @author  Javier Sanroman Araujo
 * @version $Revision: 1.1
 */

public class DatosCompartidos
{
    // Path de ejecucion del programa
    private static String PATH;

    // Paneles gui
    private static JFrameMain               frameMain;
    private static JFrameNewMapF            frameNewMapF;
    private static JFrameAdminCollection    frameAdminCollection;
    private static JPanelRight              panelRight;
    private static JFrameSearchAdvanced     frameSearchAdvanced;

    // Componentes gui
    private static JTablePersonal               tablePersonal;
    private static JTreePersonal                jTreePersonal;
    private static JTreeResultSearch            jTreeResultSearch;
    private static JTablePersonalResultSearch   tablePersonalResultSearch;
    

    // Coleccion, Mapa de ficheros, Nodo actual y Categorias de mapas de ficheros
    private static Collection               collectionActual = null;
    private static MapF                     mapFActual = null;
    private static Node                     nodeActual = null;
    private static Cat[]                    aCat = null;


    private static Hashtable                iconMime = new Hashtable();//---
    private static Collection[]             aCollection;//---

    // Opcion por defecto para los grupos de ficheros
    private static GroupFile                groupFileSinFiltro;

    // Especificamos el criterio de ordenamiento de los mapas de ficheros
    // 1 - Por orden ascendente y alfabeticamente por el nombre
    // 2 - Por orden descendente y alfabeticamente por el nombre
    // 3 - Por orden ascendente y por el numero de resultados
    // 4 - Por orden descendente y por el numero de resultados
    public static int                      ordenMapF;


    static
    {
        groupFileSinFiltro = new GroupFile( -1, "No filtrar por grupo de fichero","" );
        
        panelRight = new JPanelRight();
        
        PATH = new File("").getAbsolutePath ();

        jTreePersonal = new fmap.gui.jTreePersonal.JTreePersonal ();
        
        jTreeResultSearch           = new JTreeResultSearch();
        tablePersonalResultSearch   = new JTablePersonalResultSearch ();
        
        
        collectionActual = new fmap.actions.collection.GetCollectionAction().GetCollectionAction ( 1 );
        tablePersonal = new JTablePersonal ();
        aCollection = new CollectionDao().selectCollections ();
        
        aCat        = new GetCatsAction().GetCatsAction ();


        /** Inicializamos la tabla con los valores extension => icono correspondiente  **/
        iconMime.put ("doc", "doc.png" );
        iconMime.put ("pdf", "pdf.png" );
        iconMime.put ("php", "php.png" );
        iconMime.put ("xls", "xls.png" );
        iconMime.put ("htm", "html.png" );
        iconMime.put ("html", "html.png" );
        iconMime.put ("xml", "html.png" );
        iconMime.put ("asp", "html.png" );
        iconMime.put ("js", "html.png" );
        iconMime.put ("jsp", "html.png" );
        
        // Imagenes
        iconMime.put ("gif", "img.png" );
        iconMime.put ("img", "img.png" );
        iconMime.put ("bmp", "img.png" );
        iconMime.put ("jpg", "img.png" );
        iconMime.put ("jpeg", "img.png" );
        iconMime.put ("png", "img.png" );
        
        iconMime.put ("sql", "sql.png" );
        iconMime.put ("zip", "zip.png" );
        iconMime.put ("tar", "tar.png" );
        iconMime.put ("gz", "tar.png" );
        iconMime.put ("rar", "tar.png" );
        iconMime.put ("sh", "sh.png" );
        iconMime.put ("bat", "sh.png" );
        iconMime.put ("txt", "txt.png" );
        
        // Musica
        iconMime.put ("mp3", "mp3.png" );
        iconMime.put ("wav", "mp3.png" );
        iconMime.put ("wma", "mp3.png" );
        iconMime.put ("m3u", "mp3.png" );
        
        // Ejecutables
        iconMime.put ("exe", "exe.png" );
        iconMime.put ("bin", "exe.png" );

        /********************************************************************************/
    
    }


    synchronized public static JFrameSearchAdvanced getJFrameSearchAdvanced()
    {
        return frameSearchAdvanced;
    }

    synchronized public static void setJFrameSearchAdvanced( JFrameSearchAdvanced _frameSearchAdvanced )
    {
        frameSearchAdvanced = _frameSearchAdvanced;
    }

    
    synchronized public static GroupFile getGroupFileSinFiltro()
    {
        return groupFileSinFiltro;
    }


    synchronized public static Collection[] getACollection()
    {
        return aCollection;
    }

    synchronized public static void setACollection( Collection[] _aCollection )
    {
        aCollection = _aCollection;
    }
    
    
    synchronized public static Cat[] getACat()
    {
        return aCat;
    }

    synchronized public static void setACat( Cat[] _aCat )
    {
        aCat = _aCat;
    }


    synchronized public static Node getNodeActual( )
    {
        return nodeActual;
    }

    synchronized public static void setNodeActual( Node _n )
    {
        nodeActual = _n;
    }


    synchronized public static String getIconMime( String ext )
    {
        if ( iconMime.get (ext) != null )
            return iconMime.get (ext).toString ();
        else
            return iconMime.get ("txt").toString ();
    }
    
    synchronized public static void setPath( String _PATH )
    {
        PATH = _PATH;
    }
    
    synchronized public static String getPath(  )
    {
        return PATH;
    }

    synchronized public static void setJFrameMain( JFrameMain _frameMain )
    {
        frameMain = _frameMain;
    }

    synchronized public static void setJFrameNewMapF( JFrameNewMapF _frameNewMapF )
    {
        frameNewMapF = _frameNewMapF;
    }
    
    synchronized public static void setJTablePersonal( JTablePersonal _tablePersonal )
    {
        tablePersonal = _tablePersonal;
    }
    
    synchronized public static JTablePersonal getJTablePersonal ()
    {
        return tablePersonal;
    }

    
    synchronized public static JTablePersonalResultSearch getJTablePersonalResultSearch ()
    {
        return tablePersonalResultSearch;
    }

    
    synchronized public static void setCollectionActual( Collection _collection)
    {
        collectionActual = _collection;
    }
    
    synchronized public static Collection getCollectionActual ()
    {
        return collectionActual;
    }

    synchronized public static void setMapFActual( MapF _mapF )
    {
        mapFActual = _mapF;
    }
    
    synchronized public static MapF getMapFActual ()
    {
        return mapFActual;
    }


    synchronized public static final JPanelRight getPanelRight()
    {
        return panelRight;
    }
    
    synchronized public static final JFrameMain getJFrameMain()
    {
        return frameMain;
    }

    synchronized public static JFrameNewMapF getJFrameNewMapF()
    {
        return frameNewMapF;
    }


    synchronized public static void setJTreePersonal ( JTreePersonal _jTreePersonal )
    {
        jTreePersonal = _jTreePersonal;
    }

    synchronized public static JTreePersonal getJTreePersonal ()
    {
        return jTreePersonal;
    }

    synchronized public static void setJTreeResultSearch ( JTreeResultSearch _jTreeResultSearch )
    {
        jTreeResultSearch = _jTreeResultSearch;
    }
    
    synchronized public static JTreeResultSearch getJTreeResultSearch ()
    {
        return jTreeResultSearch;
    }
    
    synchronized public static void setJFrameAdminCollection( JFrameAdminCollection _frameAdminCollection )
    {
        frameAdminCollection = _frameAdminCollection;
    }
    
    synchronized public static JFrameAdminCollection getJFrameAdminCollection()
    {
        return frameAdminCollection;
    }
    
}
